<!DOCTYPE html>
<html>
<head>
    <title>添加医生--中软高科-2015</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/jquery.sorted.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
    $(function () {       
		$('#backid').click(function(){
				window.location.href="index.html";
		 });
    });
    </script>
</head>
<body>
<form id="addForm" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">姓名</td>
        <td>
            <input type="text" name="doctorName" id="doctorName" value=""/></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">身份证号</td>
        <td><input type="text" name="idNumber" id="idNumber" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">手机</td>
        <td><input type="text" name="phone" id="phone" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">座机</td>
        <td><input type="text" name="telPhone" id="telPhone" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td><input type="radio" name="sex" id="nan" value="1" checked/>男&nbsp;&nbsp;&nbsp;
            <input type="radio"
                   name="sex" id="nv"
                   value="0"/>女
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">出生年月</td>
        <td><input type="date" name="bday" id="bday" value=""/></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td>
            <input type="text" id="age" name="age" value=""></div>
        </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">电子邮箱</td>
        <td>
            <input type="text" name="email" id="email" value=""/><span id="checkEmail"></span>
       </td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">所属科室</td>
        <td><select id="department" name="department"></select></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">学历</td>
        <td><select id="eduction" name="eduction">
            <option value="专科">专科</option>
            <option value="本科">本科</option>
            <option value="博士">博士</option>
            <option value="博士后">博士后</option>
        </select></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">备注</td>
        <td><textarea id="description" name="description"></textarea></td>
    </tr>
    <tr>
        <td colspan="2">
			<center>
				<input class="btn btn-primary" type="button" value="保存" onclick="add()">&nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center>
		</td>
    </tr>
</table>
</form>
</body>
<script>
    findDept();
    function findDept() {
        $.ajax({
            type: "GET",
            url: "/dept/findDept",
            dataType: "json",
            success: function (vo) {
                let data = vo.list;

                let str = "";
                for (let i = 0; i < data.length; i++) {

                        str += "<option  value=\" " + data[i].deptId + "\" >" + data[i].deptName + "</option>\n"


                }
                $("#department").html(str);

            },
        })

    }
    function add(){
        $.ajax({
            type: "POST",
            url: "/Doctor/doAdd",
            data: $('#addForm').serialize(),
            dataType: "json",
            success: function (vo) {
                alert("修改成功")
                window.location.href="index.html";
            },
            error:function (vo){
                alert("添加失败")
            }
        })
    }
    $("#email").blur(function (){
      strEmail = $("#email").val()
        isEmail(strEmail);
    })
    function isEmail(strEmail){
        //定义正则表达式的变量:邮箱正则
        let reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
        //文本框不为空，并且验证邮箱正则成功，给出正确提示
        if(strEmail != null && strEmail.search(reg) != -1)
        {
            document.getElementById("checkEmail").innerHTML = "<font color='green' size='4px'>√邮箱格式正确！</font>";
        }else{
            document.getElementById("checkEmail").innerHTML = "<font color='red' size='4px'>邮箱格式错误！</font>";
        }
    }

</script>
</html>